/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Dice.java
 *
 * Created on 10.08.2011, 10:34:07
 */

package knazzy.gui;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JLabel;

/**
 *
 * @author 76167
 */
public class Dice extends javax.swing.JPanel {
    /** Creates new form Dice */

    private boolean first=false;
    private int diceNumber=0;
    private boolean locked=false;

    public Dice() {
        initComponents();
    }
    public Dice(boolean pFirst){
        first = pFirst;
        initComponents();
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        GradientPaint gp = new GradientPaint((this.getWidth()), this.getHeight()/4, Color.white, this.getWidth(), this.getHeight(), Color.gray);
        g2.setPaint(gp);
        g2.fillRect(0, 0, this.getWidth(), this.getHeight());

        
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblPips = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        lblPips.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
        lblPips.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblPips.setText("1");
        lblPips.setMaximumSize(new java.awt.Dimension(58, 58));
        lblPips.setMinimumSize(new java.awt.Dimension(58, 58));
        lblPips.setPreferredSize(new java.awt.Dimension(58, 58));
        lblPips.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblPipsMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblPips, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblPips, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void lblPipsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPipsMouseClicked
        if(this.locked == false){
            this.getLblPips().setForeground(Color.red);
            this.locked = true;
        }else{
            this.getLblPips().setForeground(Color.black);
            this.locked = false;
        }
    }//GEN-LAST:event_lblPipsMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblPips;
    // End of variables declaration//GEN-END:variables

    public int getDiceNumber() {
        return diceNumber;
    }

    public void setDiceNumber(int diceNumber) {
        this.diceNumber = diceNumber;
    }

    public JLabel getLblPips() {
        return lblPips;
    }

    public boolean isLocked() {
        return locked;
    }

    public void setLocked(boolean locked) {
        this.locked = locked;
    }
    

    

}
